package com.ayoka.parenting.ui.grown.list;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.ayoka.parenting.Constants;
import com.ayoka.parenting.R;
import com.ayoka.parenting.adapter.CommonFragmentPagerAdapter;
import com.ayoka.parenting.databinding.ActivityGrownListBinding;
import com.ayoka.parenting.mvp.MVPBaseActivity;
import com.jincp.common.model.ToolBarOptions;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: GrownListActivity.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class GrownListActivity extends MVPBaseActivity<ActivityGrownListBinding, GrownListContract.View, GrownListPresenter> {

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, GrownListActivity.class);
        activity.startActivity(intent);
    }

    private CommonFragmentPagerAdapter pageAdapter;

    @Override
    protected int getContentLayout() {
        return R.layout.activity_grown_list;
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions(R.string.classroom_center);
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        configFragments();
    }

    @Override
    protected GrownListPresenter getPresenter() {
        return null;
    }


    public void configFragments() {
        pageAdapter = new CommonFragmentPagerAdapter(getSupportFragmentManager());

        // 体验课
        GrownListFragment testCourseFragment = GrownListFragment.newInstance(Constants.ClassroomType.TEST);
        pageAdapter.addFragment(testCourseFragment, getString(R.string.test_course));

        // 成长课
        GrownListFragment electronicPresentCardFragment = GrownListFragment.newInstance(Constants.ClassroomType.GROW);
        pageAdapter.addFragment(electronicPresentCardFragment, getString(R.string.grown_course));

        mDataBinding.viewPager.setAdapter(pageAdapter);
        mDataBinding.viewPager.setOffscreenPageLimit(pageAdapter.getCount());
        mDataBinding.tabLayout.setupWithViewPager(mDataBinding.viewPager);
    }
}
